import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:vape_xe/services/services.dart';
import 'package:vape_xe/utils/utils.dart';
import 'package:vape_xe/widgets/widgets.dart';

import 'logic.dart';

class AccountInfoView extends GetView<AccountInfoController> {
  const AccountInfoView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios_new_rounded),
          onPressed: () => {Navigator.of(context).pop('刷新')},
        ),
      ),
      body: Column(
        children: [
          28.hGap,
          Container(
            margin: EdgeInsets.symmetric(horizontal: 18.w),
            decoration: BoxDecoration(
              color: Colors.white10,
              borderRadius: 12.radius,
            ),
            child: Column(
              children: [
                GestureDetector(
                  // onTap: () => controller.onTap(0),
                  child: SizedBox(
                    height: 52.h,
                    child: Row(
                      children: [
                        20.vGap,
                        Text(
                          'Portrait'.tr,
                          style: const TextStyle(fontFamily: 'Montserrat', fontWeight: FontWeight.bold),
                        ),
                        const Spacer(),
                        Obx(
                          () => netImageCached(
                            controller.avatar,
                            width: 36.w,
                            height: 36.w,
                            radius: 100.w,
                            fit: BoxFit.cover,
                          ),
                        ),
                        8.vGap,
                        Image.asset('assets/images/ic_arrow_right_white.webp', width: 10.w, height: 10.w),
                        20.vGap
                      ],
                    ),
                  ),
                ),
                Divider(color: Colors.white10, height: 1.h),
                GestureDetector(
                  onTap: () => Get.dialog(NicknameDialogView(nickName: UserStore.to.profile.nickName ?? ''),
                      barrierDismissible: false),
                  child: SizedBox(
                    height: 52.h,
                    child: Row(
                      children: [
                        20.vGap,
                        Text(
                          'Nickname'.tr,
                          style: const TextStyle(fontFamily: 'Montserrat', fontWeight: FontWeight.bold),
                        ),
                        const Spacer(),
                        Obx(
                          () => Text(
                            controller.nickName,
                            style: const TextStyle(fontFamily: 'Montserrat'),
                          ),
                        ),
                        8.vGap,
                        Image.asset('assets/images/ic_arrow_right_white.webp', width: 10.w, height: 10.w),
                        20.vGap
                      ],
                    ),
                  ),
                )
              ],
            ),
          ),
          20.hGap,
          Container(
            margin: EdgeInsets.symmetric(horizontal: 18.w),
            decoration: BoxDecoration(
              color: Colors.white10,
              borderRadius: 12.radius,
            ),
            child: Column(
              children: [
                GestureDetector(
                  onTap: () => controller.onTap(0),
                  child: SizedBox(
                    height: 52.h,
                    child: Row(
                      children: [
                        20.vGap,
                        Text(
                          'Phone number'.tr,
                          style: const TextStyle(fontFamily: 'Montserrat', fontWeight: FontWeight.bold),
                        ),
                        const Spacer(),
                        Text(
                          UserStore.to.profile.mobile ?? 'To be added'.tr,
                          style: const TextStyle(fontFamily: 'Montserrat'),
                        ),
                        8.vGap,
                        Image.asset('assets/images/ic_arrow_right_white.webp', width: 10.w, height: 10.w),
                        20.vGap
                      ],
                    ),
                  ),
                ),
                Divider(color: Colors.white10, height: 1.h),
                GestureDetector(
                  onTap: () => controller.onTap(1),
                  child: SizedBox(
                    height: 52.h,
                    child: Row(
                      children: [
                        20.vGap,
                        Text(
                          'Email'.tr,
                          style: const TextStyle(fontFamily: 'Montserrat', fontWeight: FontWeight.bold),
                        ),
                        const Spacer(),
                        Text(
                          UserStore.to.profile.email ?? 'To be added'.tr,
                          style: const TextStyle(fontFamily: 'Montserrat'),
                        ),
                        8.vGap,
                        Image.asset('assets/images/ic_arrow_right_white.webp', width: 10.w, height: 10.w),
                        20.vGap
                      ],
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}
